<template>
    <el-container>
                <el-main>
        <StElDynamicForm :helper-form="helperForm" :submit-props="{method: 'get',loading: searchLoading,onSubmit:(form,data)=>{queryParams = $stObjectTools.clone(data)}}"
                         :options="OrderGoodsFormOptions" :origin-prop="{inline: true,labelWidth: '100px'}">
        </StElDynamicForm>
        <StElTable ref="steltable" :options="OrderGoodsTableOptions" @loading="(val)=>{searchLoading = val}" :datas="OrderGoodsUrl.searchList" :query-params="queryParams">
            <template #append>
                <el-table-column
                        label="操作"
                        width="200">
                    <template #default="{row,column,$index}">
                        <StElButtonGroup :group-param="{row,column,$index}" :operationMoreButtonOptions="{stype: 'link'}" :operations="tableOperations">
                        </StElButtonGroup>
                    </template>
                </el-table-column>

            </template>
        </StElTable>
        </el-main>
    </el-container>
</template>

<script>
    import OrderGoodsMixin from '../OrderGoodsMixin.js'
    export default {
        name: "OrderGoodsSearchList",
        mixins: [OrderGoodsMixin],
        props: {
        },
        computed: {
        },
        data() {
            return {
                queryParams: {
                  orderNo: this.$route.query.orderNo
                },
                searchLoading:  false,

                helperForm: {
                  orderNo: this.$route.query.orderNo
                },

                tableOperations: [{
                    label: '退款',
                    stype: 'link',
                    loading: false,
                    requestSuccess: ({groupParam}) => {
                        // 退款请求完成，重新加载数据
                      this.$refs.steltable.reloadData()
                    },
                    action: ({groupParam}) => {
                        return {
                            method: 'post',
                            url: this.OrderGoodsUrl.refund,
                            params: {orderNo: groupParam.row.orderNo,goodsIds: [groupParam.row.goodsId],remark: '后台订单商品操作退款'},
                            confirmText: `确定要退款 ${groupParam.row.goodsName}吗？该退款操作只会发起当前商品退款！如果您想订单退款请前往订单管理操作退款。`
                        }
                    }
                },

                ]
            }
        },
        methods: {
        }
    }
</script>

<style scoped>

</style>